home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / file / managers / mc-3.2 / mc-3 / mc-3.2.1 / xv / xverror.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-17  |  2.6 KB  |  78 lines

  1. /* XView error handling routines.
  2.    Copyright (C) 1995 Jakub Jelinek.
  3.    
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2 of the License, or
  7.    (at your option) any later version.
  8.    
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. #include <config.h>
  19.  
  20. #include <xview/xview.h>
  21. #include <xview/frame.h>
  22. #include <xview/notice.h>
  23.  
  24. extern Frame mcframe;
  25.  
  26. int xv_error_handler (Xv_object object, Attr_avlist avlist)
  27. {
  28.     Attr_avlist attrs;
  29.     Error_severity severity = ERROR_RECOVERABLE;
  30.     int n = 0;
  31.     char str1[64], str2[64], str3[64], str4[64], str5[64], str6[64], str7[64];
  32.     char *strs [7];
  33.     
  34.     strs [0] = str1; strs [1] = str2; strs [2] = str3; strs [3] = str4; 
  35.     strs [4] = str5; strs [5] = str6; strs [6] = str7; 
  36.     for (attrs = avlist; *attrs && n < 5; attrs = attr_next (attrs)) {
  37.         switch ((int) attrs [0]) {
  38.             case ERROR_BAD_ATTR:
  39.                 sprintf (strs [n++], "bad attribute %s",
  40.                     attr_name (attrs [1]));
  41.                 break;
  42.             case ERROR_BAD_VALUE:
  43.                 sprintf (strs [n++], "bad value (0x%x) for attribute %s",
  44.                     (int) attrs [1], attr_name (attrs [2]));
  45.                 break;
  46.             case ERROR_INVALID_OBJECT:
  47.                 sprintf (strs [n++], "invalid object (%s)",
  48.                     (char *) attrs [1]);
  49.                 break;
  50.             case ERROR_STRING:
  51.                 sprintf (strs [n++], "%s",
  52.                     (char *) attrs [1]);
  53.                 break;
  54.             case ERROR_PKG:
  55.                 sprintf (strs [n++], "Package: %s",
  56.                     ((Xv_pkg *) attrs [1])->name);
  57.                 break;
  58.             case ERROR_SEVERITY:
  59.                 severity = attrs [1];
  60.         }
  61.     }
  62.     
  63.     strcpy (strs [n++], "Dump core?");
  64.     strs [n] = NULL;
  65. #ifdef NICE_DEBUG
  66.     if (notice_prompt (mcframe, (Event *) NULL,
  67.         NOTICE_MESSAGE_STRINGS_ARRAY_PTR, strs,
  68.         NOTICE_BUTTON_YES, "Yes",
  69.         NOTICE_BUTTON_NO, "No",
  70.         NULL) == NOTICE_YES)
  71.             abort ();
  72. #endif            
  73.     if (severity == ERROR_NON_RECOVERABLE)
  74.         exit (1);
  75.         
  76.     return (XV_OK);
  77. }
  78.